unit U_mail;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, ExtCtrls;

type
  TFmes = class(TForm)
    Label1: TLabel;
    Fim: TImage;
    Label2: TLabel;
    LNkol: TLabel;
    Label3: TLabel;
    Lmcur: TLabel;
    MeMemo: TMemo;
    SpeedButton7: TSpeedButton;
    SpeedButton6: TSpeedButton;
    Label4: TLabel;
    Lfrom: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    Procedure ShowMes;
    procedure SpeedButton6Click(Sender: TObject);
    procedure SpeedButton7Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function getGameByName(name:string):integer;

var
  Fmes: TFmes;
  curmm:word;
implementation

uses struct,clunit1,hstruct,cldata,u_wrmes;

{$R *.DFM}


function getgamebyname;
var
 i:integer;
 s:string;
begin
 result:=-1;
{ for i:=0 to gl_glist.count-1 do begin
  s:=gl_glist.getinfobynum(i,1);
  if ansiuppercase(s)=ansiuppercase(name) then begin
   result:=i;
   exit;
  end;
 end;}
end;

Procedure TFmes.showmes;
var
 k,i:integer;
begin
 mememo.lines.beginupdate;
 mememo.lines.clear;
 fim.canvas.brush.color:=clbtnface;
 fim.canvas.fillrect(rect(0,0,fim.width,fim.height));
 k:=0;
 if curmm<>0 then begin
  for i:=1 to 10 do mememo.lines.add(hmar.mesar[curmm].mes[i]);
  lfrom.caption:=hrac.GetName(hmar.mesar[curmm].from);
  for i:=1 to 10 do if hmar.mesar[curmm].too[i] then begin
    mainwin.fl.draw(fim.canvas,k*12,0,i);
    k:=k+1;
  end;
 end;
 fim.refresh;
 mememo.Selstart:=0;mememo.sellength:=0;
 mememo.lines.endupdate;
 lmcur.Caption:=inttostr(curmm);
end;


procedure TFmes.FormCreate(Sender: TObject);
begin
 mememo.lines.clear;
end;

procedure TFmes.FormActivate(Sender: TObject);
begin
  mememo.enabled:=true;
  speedbutton6.enabled:=true;
  speedbutton7.enabled:=true;
  Speedbutton2.enabled:=true;
  Speedbutton1.enabled:=true;
  curmm:=1;
 if hmar.count=0 then begin
  mememo.enabled:=false;
  speedbutton6.enabled:=false;
  speedbutton7.enabled:=false;
  Speedbutton2.enabled:=false;
  Speedbutton1.enabled:=false;
  curmm:=0;
 end;
 ShowMes;
 Lnkol.Caption:=inttostr(hmar.count);
 lmcur.caption:=inttostr(curmm);
end;

procedure TFmes.SpeedButton6Click(Sender: TObject);
begin
 if curmm<hmar.count then begin
  curmm:=curmm+1;
  ShowMes;
 end;
end;

procedure TFmes.SpeedButton7Click(Sender: TObject);
begin
 if curmm>1 then begin
  curmm:=curmm-1;
  ShowMes;
 end;
end;

procedure TFmes.SpeedButton4Click(Sender: TObject);
begin
 close;
end;

procedure TFmes.SpeedButton3Click(Sender: TObject);
begin
  Newmes:=true;
  Wform.ShowModal;
  newmes:=false;
end;

procedure TFmes.SpeedButton2Click(Sender: TObject);
begin
 quote:=true;
 wform.ShowModal;
 quote:=false;
end;

procedure TFmes.SpeedButton1Click(Sender: TObject);
begin
 reply:=true;
 wform.ShowModal;
 reply:=false;
end;

procedure TFmes.SpeedButton5Click(Sender: TObject);
begin
 wform.ShowModal;
end;

procedure TFmes.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if key=27 then close;
end;

end.
